// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//

#include <nebula/trace/tracing.h>

#include <nebula/version.h>
#include <nebula/trace/tracing_internal.h>

#include <memory>

namespace nebula {

namespace util {
namespace tracing {

#ifdef NEBULA_WITH_OPENTELEMETRY

Span::Span() noexcept {
  details = std::make_unique<::nebula::internal::tracing::SpanImpl>();
}

bool Span::valid() const {
  return static_cast<::nebula::internal::tracing::SpanImpl*>(details.get())->valid();
}

void Span::reset() { details.reset(); }

#else

Span::Span() noexcept { /* details is left a nullptr */
}

bool Span::valid() const { return false; }
void Span::reset() {}

#endif

}  // namespace tracing
}  // namespace util
}  // namespace nebula
